package com.example.meituan.activity.man;

import android.os.Bundle;
import android.widget.Toast;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.example.meituan.R;
import com.example.meituan.activity.bean.AdminBean;
import com.example.meituan.activity.bean.TalkBean;
import com.example.meituan.activity.user.MessageActivity;
import com.example.meituan.activity.user.OnMessageItemClickListener;
import com.example.meituan.activity.user.adapter.MessageAdapter;
import com.example.meituan.dao.AdminDao;
import com.example.meituan.dao.TalkDao;

import java.util.List;

public class ManageMessageActivity extends AppCompatActivity implements OnMessageItemClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_manage_message);
        AdminBean currentUser= AdminDao.getUserInfo(ManageMessageActivity.this);
        List<TalkBean> talkBeans= TalkDao.getAllTalksByUserId(currentUser.getUserId());

        androidx.recyclerview.widget.RecyclerView recyclerView=findViewById(R.id.message_recyclerView);
        if (talkBeans == null || talkBeans.isEmpty()) {
            Toast.makeText(this, "没有数据显示", Toast.LENGTH_SHORT).show();
            recyclerView.setAdapter(null);
        } else {
            MessageAdapter adapter = new MessageAdapter(talkBeans,  this,2); ;
            recyclerView.setAdapter(adapter);
        }
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });
    }

    @Override
    public void toMessageView(TalkBean talkBean) {

    }
}